package com.esunny.app;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.RandomStringUtils;

import com.jenvin.bloomfilter.BloomFilter;

public class RandomStringUtilsTest {

    public static void main(String[] args) {
        double falsePositiveProbability = 0.0001;
        int expectedSize = 999999;

        Map<Long, Integer> map = new HashMap<Long, Integer>();
        BloomFilter<Long> filter = new BloomFilter<Long>(falsePositiveProbability, expectedSize);
        for (int i = 0; i < expectedSize; i++) {
            Long l = Long.valueOf(RandomStringUtils.randomNumeric(8));
            System.out.println(i);
            if (!filter.contains(l)) {
                filter.add(l);
            } else {
                if (!map.containsKey(l)) {
                    map.put(l, 2);
                } else {
                    map.put(l, map.get(l) + 1);
                }
            }
        }

        System.out.println(map.size());
        for (Map.Entry<Long, Integer> e : map.entrySet()) {
            System.out.println(String.format("%s - %s", e.getKey(), e.getValue()));
        }
    }
}
